<template>
  <view class="app-container ver-layout">
    <image class="user-icon" :src="getStudentIcon"></image>
    <view class="divider-line"></view>
    <!--  信息列表  -->
    <view v-for="(item,index) in dataList" :key="index" class="data-item hor-layout-center">
      <view class="data-key">{{ item.title }}</view>
      <view class="data-value">{{ getItemInfo(item.value) }}</view>
    </view>
  </view>
</template>

<script>
import {StudentInfoApi} from "@/api/recordStudy.js"

let ic_teacher_student_default1 = require("@/static/home/ic_student_default1.png")

let engine = new StudentInfoApi()
export default {
  name: "studentData",
  data() {
    return {
      ic_teacher_student_default1,
      studentObj: {},
      studentInfo: {},
      dataList: [
        {title: '姓 名', value: 'realname'},
        {title: '性 别', value: 'sex'},
        {title: '年 龄', value: 'age'},
        // {title: '民 族', value: '汉族'},
        {title: '出生日期', value: 'birthday'},
        {title: '联系人', value: 'main_name'},
        {title: '联系电话', value: 'phone'},
        {title: '报课专业', value: 'majors'},
        {title: '分配教师', value: 'teacher'},
        // {title: '学生排课', value: '星期三-10:00-11:00'},
        // {title: '课程顾问', value: '斯琴潇潇'},
        {title: '所在学校', value: 'school'},
        {title: '家庭住址', value: 'home_address'},
        // {title: '考核分数', value: '99'},
        // {title: '总课时费', value: '5800元'},
      ]
    }
  },
  computed: {
    getStudentIcon() {
      if (this.studentInfo.avatarurl && this.studentInfo.avatarurl.url)
        return this.studentInfo.avatarurl.url
      return this.ic_teacher_student_default1
    }
  },
  onLoad(options) {
    this.studentObj = options
    this.getStudentStudyInfo()
  },
  methods: {
    getItemInfo(key) {
      return this.studentInfo[key] || ''
    },
    getStudentStudyInfo() {
      let sid = this.studentObj.student_id
      let rid = this.studentObj.class_id
      engine.getStudentStudyInfo({sid, rid}).then(res => {
        this.studentInfo = res.data
      })
    }
  }
}
</script>

<style scoped>
.user-icon {
  width: 59px;
  height: 73px;
}

.divider-line {
  margin-top: 13px;
  width: 100%;
  height: 1px;
  background: #E5E5E5;
}

.data-item {
  height: 57px;
}

.data-key {
  width: 60px;
  text-align: justify;
  text-align-last: justify;
  display: inline-block;
  /* 文本样式 */
  font-size: 15px;
  font-family: Source Han Sans CN;
  color: #282828;
}

.data-value {
  margin-left: 27px;
  font-size: 15px;
  font-family: Source Han Sans CN;
  color: #333333;
}
</style>
